package cn.laixueit;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class TestMyBatis {
    public static void main(String[] args) throws IOException {
        // 加载核心配置文件
        InputStream stream = Resources.getResourceAsStream("mybatis.xml");

        // 得到会话工厂
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(stream);
        // 打开一个会话

        SqlSession session = sqlSessionFactory.openSession();

//        List<Object> list = session.selectList("test.findall");

//        System.out.println(list);

//        Student one = session.selectOne("test.findbyid");

//        System.out.println(one);

        Object o = session.selectOne("test.findbyid", 2);
        System.out.println(o);
    }
}
